from aspen import Response from gittip import AMOUNTS from gittip.utils import get_participant tip_suggestions = ('jeresig', 'antirez', 'wycats', 'fabpot', 'mitsuhiko', 'jtauber', 'kennethreitz', 'alex', 'taylorotwell') tip_suggestions = [{'tippee': name, 'amount': 0} for name in tip_suggestions] def _extract_username(tip): if tip['platform'] == 'github': key = 'login' elif tip['platform'] == 'bitbucket': key = 'username' else: assert tip['platform'] == 'twitter', tip # sanity check key = 'screen_name' return tip['user_info'][key] # ========================================================================== ^L participant = get_participant(request, restrict=True) tips, total, unclaimed_tips, unclaimed_total = \ participant.get_giving_for_profile() suggest_tips = (total == 0) and (user == participant) if suggest_tips: tips = tip_suggestions hero = "Giving" title = "%s - %s" % (participant.username, hero) locked = False # ========================================================================== ^L {% extends "templates/profile.html" %} {% block page %} {% for tip in tips %} {% if tip['amount'] > 0 or suggest_tips %} {% end %} {% end %} {% if unclaimed_total > 0 %} {% end %} {% for tip in unclaimed_tips %} {% if tip['amount'] > 0 %} {% end %} {% end %}
{% if participant == user %}

You give ${{ total }} per week

{% if total == 0 %}

Not sure who to give to? Here are some suggestions

{% end %} {% else %}

{{ participant.username }} gives ${{ total }} per week

{% end %}
{{ tip['tippee'] }} {% for amount in AMOUNTS %} {% end %} {% if tip['amount'] not in AMOUNTS %} {% end %}

Another ${{ unclaimed_total }} per week goes unclaimed

{{ _extract_username(tip) }} {% for amount in AMOUNTS %} {% end %} {% if tip['amount'] not in AMOUNTS %} {% end %}
{% end %}